﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using System.Data.SqlClient;
using System.Runtime.InteropServices;
using binary.Helpers;

namespace binary
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }

        public bool ReadAll = false;

        public DataTable dane = new DataTable();
        public DataTable ListaTabel;
        public delegate void Proces();



        private void btCopyFiles_Click(object sender, EventArgs e)
        {
            CopyFiles form = new CopyFiles();
            form.ShowDialog();
        }

        private void btLoadSingle_Click(object sender, EventArgs e)
        {
            ImportSingle form = new ImportSingle();
            form.ShowDialog();
        }

        private void btLoadMulti_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = DialogHelper.GetMultiConfigDialog();
            DialogResult listResult = dialog.ShowDialog();
            if (listResult == DialogResult.OK)
                ImportHelper.DoMultiImport(dialog.FileName, false);
        }

        private void wyjścieToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            

            bool autodate = false;
            string[] args = Environment.GetCommandLineArgs();

            if (args.Contains("-autodate"))
            {
                autodate = true;
                if (!File.Exists("autodate.xml"))
                {
                    MessageBox.Show("Brak pliku autodate.xml", "Brak pliku z katalogiem");
                    this.Close();
                }
            }

            if (args.Contains("-c"))
            {
                string config = ParametersHelper.GetConfigFile(args);
                if (!string.IsNullOrEmpty(config))
                {
                    if (File.Exists(config))
                    {
                        ImportHelper.DoMultiImport(config, autodate);
                        this.Close();
                    }
                    else
                        this.Close();
                }
            }

        }





        

        

        
    }
}
